package lovedna.net {
	import flash.display.LoaderInfo;
	import flash.events.Event;

	/**
	 * @author lee
	 */
	public class QueueLoader extends BaseLoadQueue {
		// 是否自动加载下一个
		protected var _auto : Boolean = true;

		public function QueueLoader(max : int = 3) {
			super(max);
			LoaderClass = BaseLoader;
		}

		public function get currentLoader() : BaseLoader {
			return _loader as BaseLoader;
		}

		public function set auto(value : Boolean) : void {
			_auto = value;
		}

		override protected function _completeHandler(e : Event) : void {
			if (_auto) {
				trigger(e, true);
			} else {
				trigger(e, false);
			}
		}

		override protected function trigger(e : Event, complete : Boolean = false) : void {
			var loaderinfo : LoaderInfo = e.target as LoaderInfo;
			_loader = loaderinfo.loader as BaseLoader;
			urlRequest = _loader.urlRequest;
			var url : String = urlRequest.url;
			dispatchEvent(e);
			if (complete) {
				finish(url);
			}
		}
	}
}
